<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
    <style>
        .title {
            line-height: 40px;
            height: 40px;
            text-indent: 10px;
        }

        .list li {
            text-indent: 10px;
            line-height: 40px;
            height: 40px;
            border: 1px solid #333;
        }
    </style>
</head>

<body>
    <div id="wrap">
        <div class="title">
            <button>替换</button>
        </div>
        <ul class="list">
            <li class="first"><span class="demo">01</span></li>
            <li>02</li>
            <li class="mid">03</li>
            <li>04</li>
            <li>05</li>
            <li class="last">06</li>
        </ul>
        <input type="text" class="search">
    </div>
</body>
<script>

    // 插入同级

    // $(ele).replaceAll(target);    用一个元素(新增的 页面中已存在的) 替换所有的 目标元素


    $("button").eq(0).click(function () {

        $("<li>", {
            // html:"",
            text: "这是新增的li",
            class: "newLi one",
            id: "demo",
            title: "hello",
            // width: 200,
            // height: 200,
            css: {
                width: 200,
                height: 200,
                background: "#6ff",
            },
            click: function () {
                console.log($(this).index());
            }
        }).replaceAll(".mid");
    })



</script>


</html>